
<template>
  <div class="ticket">
    <div class="top">
      船票预定
    </div>
    <div class="home-container">


      <div class="news-list">
        <div class="news-item" v-for="item in ticketList" :key="item.id" @click="toDetail(item)">
          <u-image style="border-radius: 20rpx" width="200" height="180" :src="item.post_url"></u-image>
          <div class="news-right">
            <div class="news-title"> {{ item.name }}</div>
            <div class="news-desc">
              {{ item.desc }}
            </div>
            <div class="tag-list">
              <div class="tag-item">
                提前30天预定
              </div>
              <div class="tag-item">
                在线退票
              </div>
            </div>
            <div class="news-desc news-price">
              <span class="price">{{ item.child_price }}</span>起/人
            </div>
          </div>
        </div>
      </div>
    </div>

  </div>
</template>
<script>
import { mapGetters } from 'vuex'
import dayjs from "dayjs";
export default {
  name: "index",
  data() {
    return {
      ticketList: [],
      dayList: [],
      currentDate: dayjs().format('MM-DD'),
      currentWeek: '',
      show: false
    }
  },
  computed: {
    ...mapGetters(['userInfo']),
  },
  onShow() {
    this.initData()
    // 计算今天是周几
    let weekNameList = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
    this.currentWeek = weekNameList[dayjs().day()]
  },
  methods: {
    initData() {
      this.$api.getShipList().then(res => {
        this.ticketList = res
      })
    },
    toDetail(item) {
      uni.navigateTo({
        url: '/pages/ticket/detail?ticketId=' + item.id
      })
    },
    changeDate1(){}
  }
}
</script>

<style lang="scss">
.ticket {
  position: relative;
  height: 100%;
  .news-list {
    padding: 0 20rpx;
    background-color: #ffffff;
    border-radius: 20rpx;
  }
  .detail-button {
    height: 40rpx;
    line-height: 32rpx;
    text-align: center;
    padding: 4rpx 20rpx;
    font-size: 24rpx;
    color: #ffffff;
    background: #FF770F;
    border-radius: 40rpx 40rpx 40rpx 40rpx;
  }
  .news-item {
    padding: 30rpx 0;
    background-color: #ffffff;
    display: flex;
    border-bottom: 1px solid #f2f2f2;
    .news-right {
      display: flex;
      flex-direction: column;
      flex-grow: 1;
      margin-left: 40rpx;
      padding-right: 12rpx;
      position: relative;
      .news-title {
        font-size: 32rpx;
        color: #333333;
        font-weight: bold;
      }
      .tag-list {
        display: flex;
        margin-top: 20rpx;
        .tag-item {
          padding: 4rpx 8rpx;
          border-radius: 4rpx;
          font-size: 20rpx;
          color: #622898;
          border: 1px solid #814eb1;
          margin-right: 10rpx;
          margin-bottom: 10rpx;
        }
      }
      .news-desc {
        font-size: 24rpx;
        color: #666666;
        margin-top: 10rpx;
        .price {
          color: #FF770F;
          font-size: 32rpx;
          line-height: 48rpx;
          padding-right: 6rpx;
        }
      }
      .news-price {
        position: absolute;
        right: 20rpx;
        bottom: -20rpx;
      }
      .news-bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 10rpx;
        .news-time {
          font-size: 24rpx;
          color: #999999;
        }
      }
    }
  }
  .custom-nav {
    position: fixed;
    top: 20rpx;
    right: 30rpx;
    z-index: 9;
    height: 55rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #F3F3F3;
  }

  .top {
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    z-index: 1;
    height: 328rpx;
    background: linear-gradient(0deg, #F3F4F4 0%, #FF9346 27%, #FF770F 43%);
    font-size: 24px;
    color: #ffffff;
    font-weight: bold;
    text-align: center;
    line-height: 140rpx;
  }
}
.home-container {
  height: 100%;
  position: absolute;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  left: 0;
  top: 0;
  width: 100%;
  z-index: 2;
  padding:140rpx 32rpx 40rpx 32rpx;
}
</style>
